package com.xcity.game.activity2;

import org.slf4j.Logger;

import com.xcity.db.entity.Activity;

import naga.x.common.Updatable;
import naga.x.service.Service;
import naga.x.service.ServiceException;

/**
 * 活动实现类
 * @author yang.li
 *
 */
public abstract class ActivityImpl implements Service, Updatable {

	protected Activity entity;
	
	protected static final Logger LOG = ActivityService2.LOG;
	
	public ActivityImpl(Activity entity) {
		this.entity = entity;
	}
	
	public Activity getEntity() {
		return entity;
	}
	
	public boolean isActive() {
		return entity.isActive();
	}
	
	/** 加载数据，初始化活动 */
	public abstract void init();
	
	/** 保存活动数据 */
	public abstract void save();

	/** 活动开始，开启活动 */
	@Override
	public abstract void startup() throws ServiceException;

	/** 活动结束，关闭活动 */
	@Override
	public abstract void shutdown() throws ServiceException;

	/** 每分钟更新一次活动 */
	@Override
	public abstract boolean update();
	
	/** 活动数据更新 */
	public abstract void setDirty();
	
}
